package com.crs.controller.user;

import com.crs.dto.UserLendDTO;
import com.crs.result.Result;
import com.crs.service.BorrowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@Slf4j
@RequestMapping("/user/borrow")
public class BorrowController {

    @Autowired
    private BorrowService borrowService;

    @PostMapping("/lend")
    public Result userLend(@RequestBody UserLendDTO userLendDTO){
        log.info("用户借用接口",userLendDTO);
        borrowService.userLend(userLendDTO);
        return Result.success();
    }

    @GetMapping("/return/{resourceId}")
    public Result userReturn(@PathVariable Long resourceId){
        log.info("用户归还物品");
        borrowService.userReturn(resourceId);
        return Result.success();
    }

    @GetMapping("/submit/{penaltyAmount}")
    public Result userSubmit(@PathVariable BigDecimal penaltyAmount,Long RecordsId){
        log.info("用户缴纳罚款");
        borrowService.userSubmit(penaltyAmount,RecordsId);
        return Result.success();
    }

}
